package com.ferry.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by daiyong
 */
public class ClassUtil {

	private static final Logger logger = LoggerFactory.getLogger(ClassUtil.class);

	private ClassUtil() {

	}

	public static void initializeClass(String className, long tolerableMillis) {
		long start = SystemClock.millisClock().time();
		try {
			Class.forName(className);
		} catch (Throwable t) {
			logger.warn("初始化类异常 className:{}, duration:{}", className, StackTraceUtil.stackTrace(t));
		}

		long duration = SystemClock.millisClock().time() - start;
		if (duration > tolerableMillis) {
			logger.warn("初始化类超过时间限制 className:{}, duration:{}", className, duration);
		}
	}

}
